See Also

RichTextBox Class  | RichTextBox Members  | Overload List

Language

Visual Basic

C#

Show All

characterSet
The array of characters for which to search.
See Also Languages ActiveReports Send feedback to Data Dynamics

Find(Char[]) Method

Searches the text of a RichTextBox control for the first instance of a character from a list of characters.

[Visual Basic]
Overloads Public Function Find( _    ByVal characterSet() As Char _ ) As Integer
[C#]
public int Find(    char[] characterSet );

Parameters

characterSet
The array of characters for which to search.

Return Type

The location within the control where the search characters were found or a negative one (-1) if the search characters are not found or an empty search character set is specified in the char parameter.

Remarks

This version of the Find method searches for the first instance of a character from a list of characters specified in the characterSet parameter and returns the location of the character. For example, you pass an array of characters containing the character 'Q'. If the control contained the text "The Quick Brown Fox", the Find method would return the value of four. An upper case character and a lower case character are considered different values in the search.

If the property returns a negative value, the characters being searched for were not found within the contents of the control. You can use this method to search for a group of characters within the control. This version of the Find method assumes that the entire document contained in the control is searched for the characters. If a character from the character list provided in the method's characterSet parameter is found, the value returned by this method is a zero-based index of the character's position in the control. A space is considered a character by the method when determining the location of a character.

Example

[C#] 

private void ReportHeader_Format(object sender, System.EventArgs eArgs) 

    char[] ch = {'q'}; 
    if (!(this.rtbActiveReport.Find(ch) == -1)) 
    { 
        this.rtbActiveReport.SelectionStart = this.rtbActiveReport.Find(ch); 
        this.rtbActiveReport.SelectionLength = 2; 
        this.rtbActiveReport.SelectionColor = System.Drawing.Color.Crimson; 
    } 
}

[Visual Basic] 

Private Sub Detail_Format(ByVal sender As Object, ByVal e As System.EventArgs) Handles Detail.Format
    Dim ch As New Char
    ch = "q"
    If Not Me.RichTextBox1.Find(ch) = -1 Then
        Me.RichTextBox1.SelectionStart = Me.RichTextBox1.Find(ch)
        Me.RichTextBox1.SelectionLength = 2
        Me.RichTextBox1.SelectionColor = System.Drawing.Color.Crimson
    End If
End Sub

See Also

RichTextBox Class  | RichTextBox Members  | Overload List

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.